﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>UpdateUserPwdView</title>
    <script src="~/scripts/jquery-3.5.1.js"></script>
    <link href="~/lib/layui-v2.5.6/layui/css/layui.css" rel="stylesheet" />
</head>
<body>
    <form class="layui-form" onsubmit="return false" id="frmPwd" action="">
        <div class="layui-form-item">
            <label class="layui-form-label">旧密码</label>
            <div class="layui-input-inline">
                <input type="password" name="OldPwd" required lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">新密码</label>
            <div class="layui-input-inline">
                <input type="password" name="NewPwd" id="newPwd" required lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">确认新密码</label>
            <div class="layui-input-inline">
                <input type="password" name="ReNewPwd" id="newPwd1" required lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="formDemo">确认修改</button>
            </div>
        </div>

    </form>
    <script src="~/lib/layui-v2.5.6/layui/layui.js"></script>
    <script>
        //Demo
        layui.use('form', function () {
            var form = layui.form;

            //监听提交
            form.on('submit(formDemo)', function (data) {
                var pwd = $("#newPwd").val();
                var pwd2 = $("#newPwd1").val();
                if (pwd == pwd2) {
                    layer.confirm('确定修改密码吗?', { icon: 1, title: '提示' }, function (index) {
                        //do something
                        //console.log(12123)
                        var con = $("#frmPwd").serialize();
                        $.ajax({
                            url: "/Home/UpdateUserPwd",
                            type: "post",
                            data: con,
                            success: function (re) {
                                if (re.success) {
                                    layer.msg(re.msg);
                                    setTimeout(function () {
                                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                                        parent.layer.close(index); //再执行关闭
                                    }, 1900);
                                    return false;
                                } else {
                                    layer.msg(re.msg);
                                }
                            }


                        });
                        layer.close(index);
                    });
                } else {
                    layer.msg("两次密码输入不一致");
                }
                return false;
            });
        });
    </script>
</body>
</html>
